package jp.co.kayo.gae.takidashibot.controller;

import java.util.List;

import jp.co.kayo.gae.takidashibot.meta.TakidasiMeta;
import jp.co.kayo.gae.takidashibot.meta.TweetInfoMeta;
import jp.co.kayo.gae.takidashibot.model.TweetInfo;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.Transaction;

public class MntController extends Controller {

    @Override
    public Navigation run() throws Exception {
        
        TakidasiMeta mt  = TakidasiMeta.get();
        List<Key> keys = Datastore.query(mt).asKeyList();
        for(Key k : keys){
            Transaction t = Datastore.beginTransaction();
            Datastore.delete(k);
            t.commit();
        }
        
        TweetInfoMeta tti = TweetInfoMeta.get();
        List<Key> ttis = Datastore.query(tti).asKeyList();
        for(Key k : ttis){
            Transaction t = Datastore.beginTransaction();
            Datastore.delete(k);
            t.commit();
        }
        
        
        return null;
    }
}
